using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;
using THSLib;using THSERP.BaseProvider;

namespace THSERP.Modules.Report
{
    public partial class BRRP022POSsGridControl : THSGridControl
    {
        protected override DevExpress.XtraGrid.Views.Grid.GridView InitializeGridView()
        {
            base.InitializeGridView();
            DevExpress.XtraGrid.Views.Grid.GridView gridView = base.InitializeGridView();
            gridView.OptionsView.ShowFooter = true;
            gridView.OptionsCustomization.AllowFilter = true;
            gridView.OptionsView.ShowAutoFilterRow = true;
            DevExpress.XtraGrid.Columns.GridColumn colTotalAmt = gridView.Columns["BRPOSTotalAmount"];
            colTotalAmt.SummaryItem.FieldName = "BRPOSTotalAmount";
            colTotalAmt.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colTotalAmt.SummaryItem.DisplayFormat = "{0:n2}";

            DevExpress.XtraGrid.Columns.GridColumn colSubTotalAmt = gridView.Columns["BRPOSSubTotalAmount"];
            colSubTotalAmt.SummaryItem.FieldName = "BRPOSSubTotalAmount";
            colSubTotalAmt.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colSubTotalAmt.SummaryItem.DisplayFormat = "{0:n2}";

            //DevExpress.XtraGrid.Columns.GridColumn colCost = gridView.Columns["ARInvoiceItemTotalCost"];
            //colCost.SummaryItem.FieldName = "ARInvoiceItemTotalCost";
            //colCost.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            //colCost.SummaryItem.DisplayFormat = "{0:n2}";
            //int visibleIndex =0;
            //foreach (DevExpress.XtraGrid.Columns.GridColumn column in gridView.Columns)
            //{
            //    if (column.FieldName != "ARInvoiceItemProductAttribute")
            //    {
            //        column.VisibleIndex = visibleIndex;
            //        visibleIndex++;
            //    }
            //}
           
            return gridView;
        }

        protected override void GridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            //base.GridView_FocusedRowChanged(sender, e);
            DevExpress.XtraGrid.Views.Grid.GridView gridView = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView;
            int iRowHandle = gridView.FocusedRowHandle;
            if (iRowHandle >= 0)
            {
                int iObjectID = Convert.ToInt32(gridView.GetRowCellValue(iRowHandle, "BRPOSID"));
                ((RP022)this.Screen).InvalidatePOS(iObjectID);
            }
        }
        protected override void OnClick(EventArgs ev)
        {
            DevExpress.XtraGrid.Views.Grid.GridView gridView = (DevExpress.XtraGrid.Views.Grid.GridView)this.MainView;
            int iRowHandle =gridView.FocusedRowHandle;
            if ( iRowHandle>= 0)
            {
                int iObjectID = Convert.ToInt32(gridView.GetRowCellValue(iRowHandle, "BRPOSID"));
                ((RP022)this.Screen).InvalidatePOS(iObjectID);
            }
        }
    }
}
